// count reducer
import { INCREMENT, DECREMENT } from '../instance'

// 初始值
const count = 0

export default function countReducer(preState = count, action) {
  // 从action中解构类型和数据
  const { type, data } = action
  switch (type) {
    //加操作
    case INCREMENT:
      return preState + data
    //   减操作
    case DECREMENT:
      return preState - data
    default:
      // 返回默认值
      return preState
  }
}
